import { instance } from '../request'

const request = instance

/**
 * 获取角色权限详情
 *
 * @param roleId 角色id
 * @return s
 */
export const getRolePermissionsDetailApi = (
  roleId: string
): PromiseRes<{
  permissionIdList: string[]
  permissionInfoList: string[]
  permissionsList: PermissionItf[]
}> => request.get(`/rolePermissions/rolePermissionsDetail/${roleId}`)

/**
 * 为角色设置权限
 *
 * @param roleId            角色id
 * @param type           类型（refresh, add, remove）
 * @param permissionsIdList 权限id 列表
 * @return s
 */
export const setRolePermissionsApi = (
  roleId: string,
  type: 'refresh' | 'add' | 'remove',
  permissionsIdList: string[]
): PromiseRes =>
  request.post(
    `/rolePermissions/setRolePermissions/${roleId}?type=${type}`,
    permissionsIdList
  )
